package com.nmf.pc.interceptor;

import com.nmf.site.biz.member.gen.entity.BizMember;

public class PcAccountContext {

	private static final ThreadLocal<PcAccountContext> contextCache = new ThreadLocal<>();

	private String token;
	private String telNo;
	private BizMember bizMember;
	private boolean isMobile =false;
	
	
	public static boolean isMobile() {
		PcAccountContext pcAccountContext =  getCtx();
		return pcAccountContext.isMobile;
	}

	public static void setMobile(boolean isMobile) {
		PcAccountContext pcAccountContext =  getCtx();
		pcAccountContext.isMobile = isMobile;
	}

	private PcAccountContext() {

	}

	private static PcAccountContext getCtx() {
		PcAccountContext context = contextCache.get();
		if (context == null) {
			context = new PcAccountContext();
			contextCache.set(context);
		}
		return context;
	}

	public static void remove() {
		contextCache.remove();
	}
	public static void setLoginInfo(String token,String telNo,BizMember bizMember) {
		PcAccountContext pcAccountContext =  getCtx();
		pcAccountContext.token = token;
		pcAccountContext.telNo = telNo;
		pcAccountContext.bizMember = bizMember;
	}

	public static String getToken() {
		PcAccountContext pcAccountContext =  getCtx();
		return pcAccountContext.token;
	}

	public static void setToken(String token) {
		PcAccountContext pcAccountContext =  getCtx();
		pcAccountContext.token = token;
	}

	public static String getTelNo() {
		PcAccountContext pcAccountContext =  getCtx();
		return pcAccountContext.telNo;
	}

	public static  void setTelNo(String telNo) {
		PcAccountContext pcAccountContext =  getCtx();
		pcAccountContext.telNo = telNo;
	}

	public static BizMember getBizMember() {
		PcAccountContext pcAccountContext =  getCtx();
		return pcAccountContext.bizMember;
	}

	public static void setBizMember(BizMember bizMember) {
		PcAccountContext pcAccountContext =  getCtx();
		pcAccountContext.bizMember = bizMember;
	}

	
}
